import { get } from 'lodash-es'
import { RoomFeature } from '../room-feature/types'

export class Room {
  id?: string
  hotel_id?: string
  code?: string
  room_type_id?: string
  room_floor_id?: string
  room_feature_ids: string[] = []
  features: RoomFeature[] = []
  max_occupancy?: number
  selectable?: boolean
  disabled?: boolean
  sequence?: number
  created_at?: string
  updated_at?: string
  version?: number;
  [key: string]: any

  constructor(data?: Room) {
    this.init(data)
  }
}

Room.prototype.init = function init(data?: Room) {
  this.id = get(data, 'id')
  this.hotel_id = get(data, 'hotel_id')
  this.code = get(data, 'code', '')
  this.room_type_id = get(data, 'room_type_id', '')
  this.room_floor_id = get(data, 'room_floor_id', '')
  this.room_feature_ids = get(data, 'room_feature_ids', [])
  this.features = get(data, 'features', [])
  this.max_occupancy = get(data, 'max_occupancy', 0)
  this.selectable = get(data, 'selectable', true)
  this.disabled = get(data, 'disabled', false)
  this.sequence = get(data, 'sequence', 1)
  this.created_at = get(data, 'created_at')
  this.updated_at = get(data, 'updated_at')
  this.version = get(data, 'version')
}
